package com.dianqiu.common.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;
import com.dianqiu.base.dao.impl.BaseDao;
import com.dianqiu.common.bean.DqMatchHistTO;
import com.dianqiu.common.dao.DqMatchHistDao;


@Component("dqMatchHistDao")
public class DqMatchHistDaoImpl extends BaseDao implements DqMatchHistDao{

	@Override
	public List<DqMatchHistTO> getMatchHistoryById(Integer matchId) {
		return this.getHibernateTemplate().find(" from DqMatchHistTO matchHist " +
											    " left outer join fetch matchHist.dqClubsByHomeClbId homeClubs " +
											    " left outer join fetch matchHist.dqClubsByAwayClbId awayClubs " +
											    " left outer join fetch matchHist.dqLeagues leagues " +
											    " where matchHist.mthId = " + matchId);
	}

	@Override
	public List<DqMatchHistTO> getMatchById(Integer matchId) {
		return this.getHibernateTemplate().find(" from DqMatchHistTO matchHist " +
			    " where matchHist.mthId = " + matchId);
	}

	@Override
	public List<DqMatchHistTO> getAllMatch() {
		return this.getHibernateTemplate().find(" from DqMatchHistTO matchHist " +
												" left outer join fetch matchHist.dqClubsByHomeClbId homeClubs " +
											    " left outer join fetch matchHist.dqClubsByAwayClbId awayClubs " +
											    " left outer join fetch matchHist.dqLeagues leagues " +
											    " order by matchHist.mthDate desc" 
											    );
	}


	@Override
	public void save(DqMatchHistTO matchHist) {
		// TODO Auto-generated method stub
		this.getHibernateTemplate().save(matchHist);
	}


	
}